
***********************************************************
*************************Balance Tests ALL TOGETHER -- AFTER ALL 5 ARE UPDATED *******
***********************************************************

*Pooled Tests

cd ""

use "pared_balance_experiment_1.dta", clear
append using "pared_balance_experiment_2.dta"
append using "pared_balance_experiment_3.dta"
append using "pared_balance_experiment_4.dta"
append using "pared_balance_experiment_5.dta"

egen age_std=std(age), mean(0) std(1)

regress age_std same_party
regsave same_party using "balance_experiments_1_5_pooled.dta", detail(all) addlabel(outcome, age, experiment, P) replace 


foreach var in  male educ white democrat_respondent ideo5 employed straight trans religiosity poli_interest income {
egen `var'_std=std(`var'), mean(0) std(1)
regress `var'_std same_party
regsave same_party using "balance_experiments_1_5_pooled.dta", detail(all) addlabel(outcome, `var', experiment, P) append 
}

foreach var in attractiveness_scorem respond_messagem go_datem relationshipm set_up_friendm agem malem educm whitem democrat_respondentm ideo5m employedm straightm transm religiositym poli_interestm incomem {

bysort experiment: sum `var'

}

foreach var in attractiveness_scorem respond_messagem go_datem relationshipm set_up_friendm agem malem educm whitem democrat_respondentm ideo5m employedm straightm transm religiositym poli_interestm incomem {

tab `var'

}

foreach var in attractiveness_scorem respond_messagem go_datem relationshipm set_up_friendm agem malem educm whitem democrat_respondentm ideo5m employedm straightm transm religiositym poli_interestm incomem {

regress `var' same_party

}

sum attractiveness_scorem respond_messagem go_datem relationshipm set_up_friendm agem malem educm whitem democrat_respondentm ideo5m employedm straightm transm religiositym poli_interestm incomem



**** Treatment Heterogeneity pooled
gen above_median_age=1 if age>35 & age~=. 
replace above_median_age=0 if age<=35

gen above_median_educ=1 if educ>=5 & educ~=. 
replace above_median_educ=0 if educ<5

gen above_median_relig=1 if religiosity>2 & religiosity~=. 
replace above_median_relig=0 if religiosity<=2

gen above_median_interest=1 if poli_interest>=3 & poli_interest~=. 
replace above_median_interest=0 if poli_interest<3

gen above_median_income=1 if income>=6 & income~=. 
replace above_median_income=0 if income<6

foreach var in attractiveness_score respond_message go_date relationship set_up_friend {
egen `var'_s=std(`var'), mean(0) std(1)
}




regress attractiveness_score_s same_party##above_median_age i.experiment
regsave 1.same_party#1.above_median_age using "hets_studies_1_5_pooled.dta", detail(all) addlabel(het, Age, outcome, attractiveness_score, experiment, P) replace 


foreach var in  respond_message go_date relationship set_up_friend {
regress `var'_s same_party##above_median_age i.experiment
regsave 1.same_party#1.above_median_age using "hets_studies_1_5_pooled.dta", detail(all) addlabel(het, Age, outcome, `var', experiment, P) append 

}

foreach var in attractiveness_score respond_message go_date relationship set_up_friend {
regress `var'_s same_party##male i.experiment
regsave 1.same_party#1.male using "hets_studies_1_5_pooled.dta", detail(all) addlabel(het, Male, outcome, `var', experiment, P) append 

}

foreach var in attractiveness_score respond_message go_date relationship set_up_friend {
regress `var'_s same_party##above_median_educ i.experiment
regsave 1.same_party#1.above_median_educ using "hets_studies_1_5_pooled.dta", detail(all) addlabel(het, Education, outcome, `var', experiment, P) append 

}

foreach var in attractiveness_score respond_message go_date relationship set_up_friend {
regress `var'_s same_party##straight i.experiment
regsave 1.same_party#1.straight using "hets_studies_1_5_pooled.dta", detail(all) addlabel(het, Straight, outcome, `var', experiment, P) append 

}

foreach var in attractiveness_score respond_message go_date relationship set_up_friend {
regress `var'_s same_party##trans i.experiment
regsave 1.same_party#1.trans using "hets_studies_1_5_pooled.dta", detail(all) addlabel(het, Transgender, outcome, `var', experiment, P) append 

}

foreach var in attractiveness_score respond_message go_date relationship set_up_friend {
regress `var'_s same_party##above_median_relig i.experiment
regsave 1.same_party#1.above_median_relig using "hets_studies_1_5_pooled.dta", detail(all) addlabel(het, Religiosity, outcome, `var', experiment, P) append 

}

foreach var in attractiveness_score respond_message go_date relationship set_up_friend {
regress `var'_s same_party##above_median_interest i.experiment
regsave 1.same_party#1.above_median_interest using "hets_studies_1_5_pooled.dta", detail(all) addlabel(het, Political Interest, outcome, `var', experiment, P) append 

}

foreach var in attractiveness_score respond_message go_date relationship set_up_friend {
regress `var'_s same_party##employed i.experiment
regsave 1.same_party#1.employed using "hets_studies_1_5_pooled.dta", detail(all) addlabel(het, Employed, outcome, `var', experiment, P) append 
}

foreach var in attractiveness_score respond_message go_date relationship set_up_friend {
regress `var'_s same_party##above_median_income i.experiment
regsave 1.same_party#1.above_median_income using "hets_studies_1_5_pooled.dta", detail(all) addlabel(het, Income, outcome, `var', experiment, P) append 

}
foreach var in attractiveness_score respond_message go_date relationship set_up_friend {
regress `var'_s same_party##married i.experiment
regsave 1.same_party#1.married using "hets_studies_1_5_pooled.dta", detail(all) addlabel(het, Married, outcome, `var', experiment, P) append 

}


use "hets_studies_1_5_pooled.dta", clear

gen t=coef/stderr

gen significant=1 if t>1.96 | t<-1.96
replace significant=0 if significant==.

replace outcome="Set up Friend" if outcome=="set_up_friend"
replace outcome="In a Relationship" if outcome=="relationship"
replace outcome="Go on a Date" if outcome=="go_date"
replace outcome="Respond to Message" if outcome=="respond_message"
replace outcome="Attractiveness" if outcome=="attractiveness_score"

replace var="Above Median Age (p)" if var=="1.same_party#1.above_median_age"
replace var="Above Median Education" if var=="1.same_party#1.above_median_educ"
replace var="Above Median Income" if var=="1.same_party#1.above_median_income"
replace var="Above Median Political Interest" if var=="1.same_party#1.above_median_interest"
replace var="Above Median Religiosity" if var=="1.same_party#1.above_median_relig"
replace var="Employed" if var=="1.same_party#1.employed"
replace var="Male (p)" if var=="1.same_party#1.male"
replace var="Straight" if var=="1.same_party#1.straight"
replace var="Transgender" if var=="1.same_party#1.trans"
replace var="Married (p)" if var=="1.same_party#1.married"

gen ub95=coef + 1.96*stderr
gen lb95=coef - 1.96*stderr

gen range95=.
replace range95=ub95 - lb95 if lb95>0 & ub95>0
replace range95=ub95 - lb95 if lb95<0 & ub95<0
replace range95=abs(ub95) + abs(lb95) if lb95>0 & ub95<0
replace range95=abs(ub95) + abs(lb95) if lb95<0 & ub95>0

sum range95 
sum range95 if var~="Transgender"


 saveold "hets_studies_1_5_pooled_cleaned.dta", version(12) replace
      




*Individual Ones		
use "balance_experiment_1.dta", clear
append using "cces/balance_experiment_2.dta"
append using  "mturk 2 - demand effects/balance_experiment_3.dta"
append using "mturk 3 - no engage/balance_experiment_4.dta"
append using "mturk - study 5 overall/balance_experiment_5.dta"
tostring experiment, replace
append using "balance_experiments_1_5_pooled.dta"

*replace t=coef/stderr if t==.
*gen t_abs=abs(t)

replace outcome="Income" if outcome=="income"

replace outcome="Political Interest" if outcome=="poli_interest"
replace outcome="Religiosity" if outcome=="religiosity"
replace outcome="Transgender" if outcome=="trans"
replace outcome="Straight" if outcome=="straight"
replace outcome="Employed" if outcome=="employed"
replace outcome="Ideology (5)" if outcome=="ideo5"
replace outcome="Democrat" if outcome=="democrat_respondent"
replace outcome="White" if outcome=="white"
replace outcome="Education" if outcome=="educ"
replace outcome="Male" if outcome=="male"
replace outcome="Age" if outcome=="age"


saveold "balance_experiments_1_5.dta", replace version(12)

gen significant=1 if t_abs>=1.96
replace significant=0 if t_abs<1.96

tab significant
